import { baseFontSize } from '@/config'

const baseSize = baseFontSize

// 设置rem的fontSize
function updateFontSize() {
  if(document.documentElement.clientWidth > 750) {
    document.documentElement.style.fontSize = baseSize + 'px'
  }else{
    const scale = document.documentElement.clientWidth / 750
    document.documentElement.style.fontSize = baseSize * scale + 'px'
  }
}

// 设置手机端的实际窗口高度
function updateWindowHeight() {
  let windowHeight = window.innerHeight;
  let html = <HTMLElement>document.querySelector(":root");
  if (windowHeight > 0 && html) {
      html.style.setProperty("--window-height", `${windowHeight}px`);
  }
}

updateFontSize()
updateWindowHeight()

window.onresize = function () {
  updateFontSize()
  updateWindowHeight()
}
